package com.htfyun.ft.fragment.engineer;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import com.htfyun.ft.R;
import com.htfyun.hardware.WhiteListEnum;

import java.util.List;

import androidx.annotation.NonNull;

public class FragmentWhiteListNet extends FragmentWhiteListBase {

    private final String TAG = "FragmentWhiteListNet";
    @Override
    @NonNull
    protected WhiteListEnum getWhiteListEnum() {
        return WhiteListEnum.net;
    }

    @Override
    protected String getInfo() {

        getInstallAppInfo();
        return mContext.getString(R.string.engineer_test_white_list_net);
    }

    private void getInstallAppInfo() {
        PackageManager pm = mContext.getPackageManager();

        Log.e(TAG, "time = " + System.currentTimeMillis());
        List<ApplicationInfo> installedApplications = pm.getInstalledApplications(PackageManager.GET_META_DATA);
        Log.e(TAG, "installedApplications.count = " + installedApplications.size());

        Log.e(TAG, "222time = " + System.currentTimeMillis());

        for (ApplicationInfo applicationInfo : installedApplications) {

//            if (applicationInfo != null && PackageManager.PERMISSION_GRANTED == pm
//                    .checkPermission(Manifest.permission.INTERNET,
//                            applicationInfo.packageName)) {
//                //这样就能获取到有网络权限应用的uid
//                int uid = applicationInfo.uid
//
//            }
            Log.e(TAG, "applicationInfo.uid = " + applicationInfo.uid + ", pk = " + applicationInfo.packageName);
        }


    }

}
